﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace D2DEngine.Menu
{
    public delegate void OnSelectedDelegate();

    public class D2DMenuItem
    {
        protected string text;
        protected bool selected = false;

        public OnSelectedDelegate OnSelected;

        /// <summary>
        /// The text of this menu item
        /// </summary>
        public string Text
        {
            get { return text; }
            set { text = value; }
        }

        /// <summary>
        /// Is the menu item selected ?
        /// </summary>
        public bool Selected
        {
            get { return this.selected; }
            set { this.selected = value; }
        }


        /// <summary>
        /// Constructs a new menu entry with the specified text.
        /// </summary>
        public D2DMenuItem(string text)
        {
            this.text = text;
            this.OnSelected = new OnSelectedDelegate(OnSelectedMethod);
        }

        /// <summary>
        /// The method called when the object hits the world limit
        /// </summary>
        /// <param name="obj"></param>
        protected void OnSelectedMethod()
        {
        }


        /// <summary>
        /// Updates the menu item.
        /// </summary>
        public virtual void Update(GameTime gameTime)
        {

        }


        /// <summary>
        /// Draws the menu entry. This can be overridden to customize the appearance.
        /// </summary>
        public virtual void Draw(SpriteBatch spriteBatch)
        {
            /*
            // Draw the selected entry in yellow, otherwise white.
            Color color = this.selected ? Color.Yellow : Color.White;

            // Pulsate the size of the selected menu entry.
            double time = gameTime.TotalGameTime.TotalSeconds;

            float pulsate = (float)Math.Sin(time * 6) + 1;

            float scale = 1 + pulsate * 0.05f * selectionFade;

            // Modify the alpha to fade text out during transitions.
            color = new Color(color.R, color.G, color.B, screen.TransitionAlpha);

            Vector2 origin = new Vector2(0, font.LineSpacing / 2);

            spriteBatch.DrawString(font, text, position, color, 0,
                                   origin, scale, SpriteEffects.None, 0);
             */
        }

    }
}
